//import { createAssigner } from '../core/createAssigner'
import { keys } from '../core/keys'

import { isUndef } from '../core/isUndef'
import { each } from '../core/each'
// 5370
/**
 * 类似 extend，但只复制自己的属性，不包括原型链上的属性
 * extendOwn({ name: 'RedHood' }, { age: 24 }); // -> {name: 'RedHood', age: 24}
 * dependencies keys createAssigner
 * @param {*} obj 目标对象
 * @param  {...any} sources 源对象
 * @returns 
 */
export function extendOwn (obj, ...sources) {
  //return createAssigner(keys);
  var defaults = true;
  each(arguments, function (src, idx) {
    if (idx === 0) return;
    var keyArr = keys(src);
    each(keyArr, function (key) {
      if (!defaults || isUndef(obj[key])) {
        obj[key] = src[key];
      }
    });
  });
  return obj;
}